package com.example.java.source;

import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;

public class MyParallelSource implements ParallelSourceFunction<String> {
    private Long count = 0L;
    private boolean isRunning = true;

    @Override
    public void run(SourceContext<String> ctx) throws Exception {
        while (isRunning) {
            ctx.collect((count++).toString());
            Thread.sleep(1000);
        }
    }

    @Override
    public void cancel() {
        isRunning = false;
    }
}
